package com.atguigu.weixin.controller;


import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.atguigu.weixin.json.ModelMsgData;
import com.atguigu.weixin.json.TemplateMsg;
import com.atguigu.weixin.msg.MessageKit;



/**
 * 微信接口最基本的接入
 * @author lfy
 *
 */
@Controller
public class InitWeChatController {
	

	@RequestMapping("/testtemple")
	   public void testAccessToken(HttpServletRequest req,HttpServletResponse resp) throws IOException {
		 TemplateMsg tm=new TemplateMsg();
		 tm.setTouser("oFdup00z5TSqTRmHtFhBJsP9bR1A");//用户id
		 tm.setTemplate_id("8E506-tBPQNALa4fRnWpeS9EIsL4YuSFg0T2m0TEdcQ");//模板id
		 tm.setUrl("https://www.ljxin.top/");
		 Map<String,Object> data=new HashMap<String,Object>();
		 data.put("num", new ModelMsgData("123", "#00ff00"));
		 tm.setData(data);
		 System.out.println(JSON.toJSONString(tm));
		 MessageKit.postTemplateMsg(tm);
	   }

}
